@extends('WShop::layout')
@section('content')
    @include('WShop::public.header')
    <div class="mui-content mui-scroll-wrapper" id="pullrefresh">
        <div class="mui-scroll">
            <div class="mui-table-view mui-table-view-chevron mui-bottom">
                <div class="mui-queren-dingdan ">
                    <form id="order-create" action="{{route('f_Wap_Order_submitOrder',['zone'=>$zone])}}" method="post">
                        {{csrf_field()}}
                        @if(isset($cart_id))
                            <input type="hidden" name="cart_id" value="{{$cart_id??''}}">
                        @endif
                        <input type="hidden" name="sign" value="{{$sign}}">
                        <ul class="mui-table-view bg-fff">

                            <li class="mui-table-view-cell" style="margin-bottom: 0!important;">
                                <a class="mui-navigate-right mui-clearfix post-addr" href="{{route('f_Wap_Address_myAddress')}}">
                                    <img src="{{asset(config('view.frontend.wap_login').'/images/tu33.png')}}" alt="" width="25" class="mui-pull-left" />
                                    @if($address)
                                        <div class="mui-pull-left">
                                            <div>收件人：{{$address->consignee}} &nbsp;{{$address->phone}}</div>
                                            <div>{{$address->address}}</div>
                                        </div>
                                        <input type="hidden" name="address" value="{{$address->id}}">
                                    @else
                                        <div class="mui-pull-left tianjia" style="line-height:3;">
                                            <div>收货地址 <span>未选择收货地址</span></div>
                                        </div>
                                    @endif
                                </a>
                            </li>

                            <li style="background: #f2f2f2;height: 10px;"></li>
                            <li class="mui-table-view-cell time">
                                <div class="time_header">
                                    发货时间 <span class="mui-pull-right mui-text-green">卖家承诺24小时之内发货</span>
                                </div>
                                @foreach($goods as $item)
                                    <div class="mui-dingdan-xx bg-fff flex time_bottom">
                                        <img src="{{str_first($item->goods_images)}}" alt="" class="mui-pull-left" />
                                        <div class="mui-pull-right">
                                            <h4>{{$item->goods_name}}</h4>
                                            <span style="color: #169fb7">{{$specs[$item->goods_id]??''}}</span>
                                            <div class="mui-text-left" style="position: relative;">
                                                <div style="margin-bottom: 10px;">￥<span>@if($level > 0){{$item->vip_price}}@else{{$item->price}}@endif</span> <span class="mui-pull-right">X{{$buy_num[$item->goods_id]}}</span></div>
                                                <input type="hidden" name="goods_id[]" value="{{$item->goods_id}}">
                                                <input type="hidden" name="specs[{{$item->goods_id}}]" value="{{$specs[$item->goods_id]??''}}">
                                                <input type="hidden" name="number[{{$item->goods_id}}]" value="{{$buy_num[$item->goods_id]??1}}">
                                            </div>
                                            <div style="float: right" class="color1">
                                                小计：{{$subtotal[$item->goods_id]}}
                                            </div>
                                        </div>
                                    </div>
                                @endforeach
                                <div class="time_bottom">邮费 <span class="mui-pull-right">@if($post_cost > 0){{$post_cost}} @else 包邮 @endif</span></div>

                                <div class="flex flexs">
                                    <div style="width: 100px;">订单备注：</div>
                                    <textarea name="remark" rows="" cols="" placeholder="请输入备注信息"></textarea>
                                </div>

                            </li>
                        </ul>
                        <div class="mui-title-header">支付方式</div>
                        <ul class="mui-table-view mui-table-view-radio bg-fff zhifu" style="margin-top: 0;">
{{--                            都用奖金积分支付--}}
{{--                            <li class="mui-table-view-cell mui-selected">--}}
{{--                                <a href="javascript:;" class="mui-navigate-right">--}}
{{--                                    <input type="radio" name="zhifu" checked value="102" />--}}
{{--                                    <img src="{{asset(config('mall.wap_assets1').'/images/qianbao.png')}}" alt="">--}}
{{--                                    {{get_currency()['money2']}}--}}
{{--                                    <span style="float: right;color: red;margin-right: 30px;">{{$wallet->money2}}</span>--}}
{{--                                </a>--}}
{{--                            </li>--}}

                            @if($zone == 1)
                                <li class="mui-table-view-cell mui-selected">
                                    <a href="javascript:;" class="mui-navigate-right">
                                        <input type="radio" name="zhifu" checked  value="102" />
                                        <img src="{{asset(config('mall.wap_assets1').'/images/qianbao.png')}}" alt="">
                                        {{get_currency()['money2']}}
                                        <span style="float: right;color: red;margin-right: 30px;">{{$wallet->money2}}</span>
                                    </a>
                                </li>
                            @elseif($zone == 2)
                                <li class="mui-table-view-cell mui-selected">
                                    <a href="javascript:;" class="mui-navigate-right">
                                        <input type="radio" name="zhifu" checked  value="102" />
                                        <img src="{{asset(config('mall.wap_assets1').'/images/qianbao.png')}}" alt="">
                                        {{get_currency()['money2']}}
                                        <span style="float: right;color: red;margin-right: 30px;">{{$wallet->money2}}</span>
                                    </a>
                                </li>
                            @elseif($zone == 3)
                                <li class="mui-table-view-cell mui-selected">
                                    <a href="javascript:;" class="mui-navigate-right">
                                        <input type="radio" name="zhifu" checked  value="103" />
                                        <img src="{{asset(config('mall.wap_assets1').'/images/qianbao.png')}}" alt="">
                                        {{get_currency()['money3']}}
                                        <span style="float: right;color: red;margin-right: 30px;">{{$wallet->money3}}</span>
                                    </a>
                                </li>
                            @endif

{{--                            <li class="mui-table-view-cell ">--}}
{{--                                <a href="javascript:;" class="mui-navigate-right">--}}
{{--                                    <input type="radio" name="zhifu"  value="100" />--}}
{{--                                    <img src="{{asset(config('mall.wap_assets1').'/images/onlinepay.png')}}" alt="">线下支付--}}
{{--                                </a>--}}
{{--                            </li>--}}

{{--                                <li class="mui-table-view-cell ">--}}
{{--                                    <a href="javascript:;" class="mui-navigate-right">--}}
{{--                                        <input type="radio" name="zhifu"  value="99" />--}}
{{--                                        <img src="{{asset(config('mall.wap_assets1').'/images/payonline.png')}}" alt="">在线支付--}}
{{--                                    </a>--}}
{{--                                </li>--}}

                        </ul>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="mui-bar mui-bar-footer" style=" height: 50px;">
        <div class="flex">
            <div class="flex-item">
                <div class="mui-text-red">￥ <b id="pay-count" class="count mui-text-red" data-total="{{$pay_price}}">{{$pay_price}}</b></div>
            </div>
            <div class="flex-item mui-text-right" id="submit-btn">
                <button class="mui-btns"  style="margin:0 -10px 0 0;background: #5a92fd;width: 90%;height: 50px;line-height: 50px;border-radius: 2px;float: right;">提交订单</button>
            </div>
        </div>
    </div>
@endsection
@push('scripts')
    <script>
        $('input[name="buy_type"]').on('click',function () {
            if(this.checked){
                var total = $(this).data('agent')+$('#pay-count').data('total');
                $('#pay-count').text(total);
            }
        });
        mui('.mui-bar-footer').on('tap','#submit-btn',function () {
            mui.confirm('确认提交订单？','',function(e){
                if(e.index==1){
                    new shopAjax({
                        url:$('#order-create').attr('action'),
                        data:$('#order-create').serialize(),
                        callback:function (response) {
                            window.location.href=response.url;
                        }
                    }).ajax()
                }
            })
        });
    </script>
@endpush